from game.settings import *
import MySQLdb
def selectAll(login):
   db= MySQLdb.connect(DATABASE_HOST,DATABASE_USER,DATABASE_PASSWORD,DATABASE_NAME);
   cursor= db.cursor();
   cursor.execute("SELECT * FROM long_user  WHERE login = '%s'" %(login) );
   k=cursor.fetchall();
   return t
#===============================================================================
#         us_prf={'id':ad[0],'id_user':ad[1],'jabber':ad[2],'icq':ad[3],'Skype':ad[4],\
#               'site':ad[6],'abut_author':ad[7],'show_im':ad[8],'status':ad[9]}
#===============================================================================
def EditTop(dataR):
    db= MySQLdb.connect(DATABASE_HOST,DATABASE_USER,DATABASE_PASSWORD,DATABASE_NAME);
    cursor= db.cursor();
    cursor.execute("UPDATE TOP SET  name='%s',info='%s',count=%s, pay=%s,nameL='%s',nameimg='%s'    WHERE  id_=%s"\
                    % (name,info,str(kolh),str(summa),nameC,image,str(idf) ) );
    return 0
def addProfreg(id_user):
    db= MySQLdb.connect(DATABASE_HOST,DATABASE_USER,DATABASE_PASSWORD,DATABASE_NAME);
    cursor= db.cursor();
    try:
      cursor.execute("""INSERT INTO long_user(id_user,about_author) VALUES ('%s','none info')""" % (id_user) )
      return 0
    except NameError:
      return 1
def showdate(id):
      db= MySQLdb.connect(DATABASE_HOST,DATABASE_USER,DATABASE_PASSWORD,DATABASE_NAME);
      cursor= db.cursor();
      cursor.execute("SELECT * FROM long_user WHERE  id_user=%s" % (id))
      k=cursor.fetchall();
      g=k[0]
      return g
 